package com.desire.homework;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author desire
 */
public class _02_分时问候 {
    public static void main(String[] args) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = sdf.format(new Date());
        //截取小时位
        String hh = date.substring(11, 13);
        int hours = Integer.parseInt(hh);
        if (6 <= hours && hours < 9) {
            System.out.println("早上好, 当前时间为: " + date);
        } else if (9 <= hours && hours < 12){
            System.out.println("上午好, 当前时间为: " + date);
        } else if (12 <= hours && hours < 14){
            System.out.println("中午好, 当前时间为: " + date);
        }else if (14 <= hours && hours < 18){
            System.out.println("下午好, 当前时间为: " + date);
        } else if (18 <= hours && hours < 21) {
            System.out.println("晚上好, 当前时间为: " + date);
        } else {
            System.out.println("处于休息时间.");
        }
    }
}

